import dashscope
from http import HTTPStatus


class LLM_Service:
    def call_with_messages(self, system_prompt, question_content):
        messages = [
            {'role': 'system', 'content':system_prompt},
            {'role': 'user', 'content':question_content}
        ]
        response = dashscope.Generation.call(
            api_key='sk-1510f0c5a7fd4d73ab2db5d4127e5866',
            model= 'qwen3-235b-a22b',
            # model = 'qwen-plus-latest',
            messages=messages,
            result_format = 'message',
            enable_thinking = False
            # extra_body={"enable_thinking": 'false'}
        )
        if response.status_code == HTTPStatus.OK:
            return response['output']['choices'][0]['message']['content'].strip()
        else:
            print('Request id: %s, Status code: %s, error code: %s, error messages: %s' % (
                response.request_id, response.status_code, response.code, response.message
            ))
